package com.zzh.greendaotest;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.ScrollView;

public class DemoActiivty extends AppCompatActivity {

    private static final String TAG = DemoActiivty.class.getSimpleName();

    private View title;
    private ScrollView scrollView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_demo);
        initView();
        aaa();
    }

    private void initView() {
        title = findViewById(R.id.title);
        scrollView = findViewById(R.id.scrll_View);
    }

    private void aaa() {
        scrollView.setOnScrollChangeListener(new View.OnScrollChangeListener() {
            @Override
            public void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
                Log.i(TAG, ">>>y>>>>" + scrollY);
                Log.i(TAG, ">>>old y>>>>>" + oldScrollY);
                if (scrollY == 0) {
                    title.setElevation(0);
                } else {
                    if (title.getElevation() == 0){
                        Log.i(TAG, ">>>>>>tu chu lai le  >>");
                        // TODO: 2018/8/22 这里的值可以调节阴影的度 
                        title.setElevation(20);
                    }
                }
            }
        });
    }


}
